package com.yutel.multher;

import com.yutel.multher.jas.JasLog;
import com.yutel.multher.jas.Launcher;

public class JasMain {
	private static JasLog log = JasLog.getLogger(JasMain.class);

	public static void main(String[] args) {
		System.setProperty("launcher.config",
				"file:src/main/resources/launcher.properties");
		JasMain jm = new JasMain();
		jm.start(args);
	}

	public void start(String[] args) {
		try {
			Launcher launcher = new Launcher();
			String command = "start";
			if (args.length > 0) {
				command = args[args.length - 1];
			}

			if (command.equals("start")) {
				launcher.start();
			} else if (command.equals("stop")) {
				launcher.stop();
			} else {
				log.error("Launcher: command \"" + command
						+ "\" does not exist.");
			}
		} catch (Throwable t) {
			t.printStackTrace();
			System.exit(-1);
		}
	}
}
